import unittest
import wx

from pyeasyaccept.gui.ScriptLinePanel import ScriptLinePanel
from pyeasyaccept.gui.CommandsDictionary import CommandsDictionary
from pyeasyaccept.gui.ScriptPreviewPanel import ScriptPreviewPanel
from pythoneasyaccept_test.TestFacade import TestFacade




"""
This class tests the 'ScriptLinePanel' panel
@author: Mikaela Maia
"""
class ScriptLinePanelTest(unittest.TestCase):
    
    """
    This method sets initial information
    """
    def setUp(self):
        self.app = wx.App()
        self.frame = wx.Frame(None, -1)
        self.commmadsDictionary = CommandsDictionary()
        self.spp = ScriptPreviewPanel(self.frame, -1)
        self.panel = ScriptLinePanel(self.frame, -1,self.commmadsDictionary)
        
        
    """
    This method tear down informations
    """
    def tearDown(self):
        self.app.Destroy()
        pass

    """
    This method runs the successful tests
    """
    def testScriptLinePanel(self):
        event = wx.KeyEvent(wx.WXK_EXECUTE)
        
        self.panel._ctrl.SetValue("lala")
        self.panel.OnCancel(event)
        self.assertEquals("",self.panel._ctrl.GetValue())
        
        self.panel._ctrl.SetValue("lala")
        self.panel.OnOK(event)
        self.assertEquals("",self.panel._ctrl.GetValue())
        
        self.assertTrue(self.panel.match("exp", "expect"))
    
if __name__ == '__main__':
    unittest.main() 